#include "mpsmain.h"
#include "ui_mpsmain.h"

MPSMain::MPSMain(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MPSMain)
{
    ui->setupUi(this);
    //No Frames
    setWindowFlags(Qt :: FramelessWindowHint);
}

MPSMain::~MPSMain()
{
    delete ui;
}

void MPSMain::on_pushButton_clicked()
{
    static QMovie movie(":/res/wait.gif");
    QDialog *pDlg=new QDialog();
    QLabel *label  = new QLabel(pDlg);
    //Set Dialog Modal And NoFrame
    pDlg->setModal(true);
    pDlg->setWindowModality(Qt :: ApplicationModal);
    pDlg->setAttribute(Qt::WA_DeleteOnClose);
    pDlg->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
    //set label size And scale
    label->resize(200,200);
    label->setScaledContents(true);
    //set Label Movie
    label->setMovie(&movie);
    movie.start();
    // This Will return MPSMain Event Loop ,So Disable All Btn
    pDlg->show();
    label->show();
    //do_func() In Thread;
    QtConcurrent::run([=](){
        do_func();
        pDlg->close();
    });
}

void MPSMain::on_closeBtn_clicked()
{
     this->close();
}
